import axios from '../index';
import {API_DOMAIN} from "../../utils/constants";

const LOGIN_URL = '/system/login';
const CAPTCHA_URL = '/system/getCaptchaImage';
const SENDRESETMAIL_URL = 'passports/sendResetMail';
const ASSIGNPASSWORD_URL = 'passports/assignPassword';
const LOGOUT_URL = '/system/logout';
const UPTOKEN_URL = '/qiniu/getUploadToken';
const DOWNLOAD_URL = '/qiniu/getDownloadUrl';
const UPDATE_ACCESS_TOKEN = 'system/updateAccessToken';

async function login (params) {
  return axios.post(LOGIN_URL, params);
}

async function getCaptcha (uuid) {
  return axios.post(CAPTCHA_URL, {
    s: uuid,
  });
}

async function sendResetMail (params) {
  return axios.post(SENDRESETMAIL_URL, params);
}

async function assignPassword (params) {
  return axios.post(ASSIGNPASSWORD_URL, params);
}

async function logout () {
  return axios.post(LOGOUT_URL);
}

async function getUploadToken () {
  return axios.get(UPTOKEN_URL);
}

async function getDownloadUrl (url) {
  return axios.post(DOWNLOAD_URL, { s: url });
}

async function updateAccessToken () {
  return axios.post(UPDATE_ACCESS_TOKEN);
}

async function mailLogin () {
  return axios.get('passports/bossmail/enter');
}
const shareUrl = `${API_DOMAIN}/survey/getWxShareSignature.htm?url=http://www.baidu.com`;
async function getSynologySid () {
    return axios.get('/passports/synology/login');
}

async function getWxShare (url) {
    return axios.get('/survey/getWxShareSignature.htm?url='+url);
}
export default {
  login,
  getCaptcha,
  sendResetMail,
  assignPassword,
  logout,
  getUploadToken,
  getDownloadUrl,
  updateAccessToken,
  mailLogin,
  getSynologySid,
  getWxShare,
};
